<?php
require('lib/verify.php');
require('lib/has_char.php');
require('lib/is_approved.php');

$_category = "warmath";
$_title = "Character";
require('lib/head.php');

$id = $_GET["id"];
$system_id = $system["system_id"];

$sql = "select * from wm_characters where character_id = $id and character_system_id = $system_id";
$result = $db->query($sql);


if($db->num_rows($result)<1) {
 header("Location: error-wrong-system.php");
 exit;
}


$chara = $db->fetch_assoc($result);

$id = $_GET["id"];

$sql = "select * from subc_users where id = '" . $chara["character_forum_id"] . "'";
$result = $db->query($sql);
$fora = $db->fetch_assoc($result);

boxTop("Warmath: $_title / " . $chara["character_name"]);
?>
<?cclass($chara["character_class"])?> <b><?=$chara["character_name"]?></b>
<?php
if($chara["character_forum_id"]) {
?>
 <a href="<? echo PUN_ROOT.'profile.php?id='.$fora["id"]?>"><?=$fora["username"]?></i></a> (<a href="<? echo PUN_ROOT.'message_send.php?id='.$fora["id"]?>">send PM</a>)
<?php
}
   else {
?>
<i>Not registered on the forums.</i>
<?php
   }
?>
<br /><br />
<a href="wishlist-other.php?id=<?=$id?>"><?=$chara["character_name"]?>'s Wishlist</a><br />

<br />

<b>Satout DKP</b>: <?=number_format($chara["character_dkp_satout"], 2)?><br />
<b>Earned DKP</b>: <?=number_format($chara["character_dkp_earned"], 2)?><br />
<b>Spent DKP</b>: <?=number_format($chara["character_dkp_spent"], 2)?><br />
<b>Current DKP</b>: <b><?=number_format($chara["character_dkp"], 2)?></b><br />

<br />
<b>Loot</b><br />
<?php
$sql = "select *, wm_characters.*, wm_credits.*, wm_instances.*, wm_raids.*, wm_bosses.*, wm_item_values.* from wm_loots left join wm_characters on wm_characters.character_id = loot_character left join item_cache on wm_loots.loot_item = item_cache.item_id left join wm_credits on wm_credits.credit_id = wm_loots.loot_credit left join wm_bosses on wm_bosses.boss_id = wm_credits.credit_boss left join wm_raids on wm_raids.raid_id = wm_credits.credit_raid left join wm_instances on wm_instances.instance_id = wm_bosses.boss_instance left join wm_item_values on wm_item_values.item_id = wm_loots.loot_item where loot_system_id = $system_id and loot_character=$id and wm_item_values.item_system_id=$system_id order by wm_credits.credit_date desc";
//echo $sql;
$result = $db->query($sql);
?>
<i><?=$db->num_rows($result)?> items looted.</i><br />
<?php
if($system["system_tier"]==4) {
$wish_text[1] = "Min";
$wish_text[2] = "Mod";
$wish_text[3] = "Max";
}
else {
$wish_text[1] = "Micro";
$wish_text[2] = "Min";
$wish_text[3] = "Mod";
$wish_text[4] = "Max";
}

while($loot = $db->fetch_assoc($result)) {
?>
<br />
<?php show_link(array("item_id" =>$loot["loot_item"]))?>
<?=$wish_text[$loot["loot_level"]]?> (<?=number_format($loot["loot_bid"],2)?> bid) (<?=number_format($loot["item_value"], 2)?> paid)<br />
<a href="credit.php?id=<?=$loot["credit_id"]?>"><?=$loot["boss_name"]?>, <?=date("g:i a", strtotime($loot["credit_date"]))?></a><br />
<a href="raid.php?id=<?=$loot["raid_id"]?>"><?=$loot["instance_name"]?>, <?=date("D d M Y", strtotime($loot["raid_date"]))?></a><br/>
<?php
}
?>
<br />
<b>Credits</b><br />
<?php
$sql = "select *, wm_raids.*, wm_credits.*, wm_bosses.*, wm_instances.* from wm_attendees left join wm_credits on wm_attendees.attendee_credit = wm_credits.credit_id left join wm_bosses on wm_bosses.boss_id = credit_boss left join wm_raids on wm_credits.credit_raid = wm_raids.raid_id left join wm_instances on wm_instances.instance_id = wm_bosses.boss_instance where attendee_system_id = $system_id and attendee_character=$id and attendee_satout=0 order by credit_date desc";
$result = $db->query($sql);
?>
<i><?=$db->num_rows($result)?> credits earned.</i><br />
<?php
while($cred = $db->fetch_assoc($result)) {
?>
<a href="credit.php?id=<?=$cred["credit_id"]?>"><?=$cred["boss_name"]?>, <?=date("g:i a", strtotime($cred["credit_date"]))?></a> in <a href="raid.php?id=<?=$cred["credit_raid"]?>"><?=$cred["instance_name"] . ", " . date("D d M Y", strtotime($cred["raid_date"]))?></a><br />
<?php
}
?>
<br />
<b>Satout</b><br />
<?php
$sql = "select *, wm_raids.*, wm_credits.*, wm_bosses.*, wm_instances.* from wm_attendees left join wm_credits on wm_attendees.attendee_credit = wm_credits.credit_id left join wm_bosses on wm_bosses.boss_id = credit_boss left join wm_raids on wm_credits.credit_raid = wm_raids.raid_id left join wm_instances on wm_instances.instance_id = wm_bosses.boss_instance where attendee_system_id = $system_id and attendee_character=$id and attendee_satout=1 order by credit_date desc";
$result = $db->query($sql);
?>
<i><?=$db->num_rows($result)?> times satout.</i><br />
<?php
while($cred = $db->fetch_assoc($result)) {
?>
<a href="credit.php?id=<?=$cred["credit_id"]?>"><?=$cred["boss_name"]?>, <?=date("g:i a", strtotime($cred["credit_date"]))?></a> in <a href="raid.php?id=<?=$cred["credit_raid"]?>"><?=$cred["instance_name"] . ", " . date("D d M Y", strtotime($cred["raid_date"]))?></a><br />
<?php
}
?>
<?php
boxBot();
?>

<?php
require('lib/foot.php');
?>

